﻿using DM_Sqlite.MappingClass;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DM_Sqlite
{
    public class MyDbContext:DbContext
    {
       
        public DbSet<dm_props_admin>? dm_props_admin { get; set; }
        public DbSet<dm_props_user>? dm_props_user { get; set; }
        public DbSet<dm_dbcprops_user>? dm_dbcprops_user { get; set; }
        public DbSet<dm_sysauthority>? dm_sysauthority { get; set; }

        public MyDbContext(DbContextOptions<MyDbContext> options)
           : base(options)
        {
        }
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);
            optionsBuilder.UseSqlite("Data Source=dm_sqlite.db");
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            //从当前程序集加载所有的IEntityTypeConfiguration
            modelBuilder.ApplyConfigurationsFromAssembly(this.GetType().Assembly);
        }
    }
}
